<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'', styles:'bootstrap,font-awesome,animate,style,bootstrap-table,layui-date,auto-complete,dtvalidate,layui,chosen'}){%>
    <style type="text/css">
        body{padding-top:10px;}
        *{margin:0;padding:0;list-style-type:none;}
        a,img{border:0;}
        .demo h2{font-size:16px;color:#3366cc;height:30px;}
        .demo li{float:left;}
    </style>
    <%}%>
</head>

<body>
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins" style="margin-bottom: 0px;">
                <input type="hidden" readonly id="productMember" name="productMember" class="form-control" value="${user.userRealname}">
                <div class="ibox-content" style="padding:15px 20px 0px 20px;">
                    <form id="search-form" role="form" class="form-horizontal" autocomplete="off">
                        <div class="form-group">
                            <label class="control-label col-sm-1">请购单号:</label>
                            <div class="col-sm-2">
                                <select  id="orderIds" name="orderIds" xm-select="orderIds" xm-select-search>
                                    <%for(var dict in order){%>
                                    <option value="${dict.orderId}">${dict.orderNo}</option>
                                    <%}%>
                                </select>
                            </div>
                            <label class="control-label col-sm-1">SKU:</label>
                            <div class="col-sm-2">
                                <input type="text"  name="orderSku" placeholder="请填写SKU" class="form-control">
                            </div>
                            <label class="control-label col-sm-1">产品名称:</label>
                            <div class="col-sm-2">
                                <input type="text"  name="productName" placeholder="请填写产品名称" class="form-control">
                            </div>

                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-1">颜色:</label>
                            <div class="col-sm-2">
                                <select  id="productColorIds" name="productColorIds" xm-select="productColorIds" xm-select-search>
                                    <%for(var dict in color){%>
                                    <option value="${dict.detailCode}">${dict.detailName}</option>
                                    <%}%>
                                </select>
                                <input type="hidden" id="productColorName" name="productColorName">
                            </div>
                            <label class="control-label col-sm-1">尺码:</label>
                            <div class="col-sm-2">
                                <select  id="productSizeIds" name="productSizeIds" xm-select="productSizeIds" xm-select-search>
                                    <%for(var dict in size){%>
                                    <option value="${dict.detailCode}">${dict.detailName}</option>
                                    <%}%>
                                </select>
                            </div>
                            <label class="control-label col-sm-1">供应商:</label>
                            <div class="col-sm-2">
                                <input type="text"  name="supplierName" placeholder="请填写供应商名称" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-1">渠道:</label>
                            <div class="col-sm-2">
                                <select  name="orderChannelName" id="orderChannelName" class="form-control">
                                    <option value="">请选择渠道</option>
                                    <%for(var dict in channel){%>
                                    <option value="${dict.channelName}"  >${dict.channelName}</option>
                                    <%}%>
                                </select>
                            </div>
                            <label class="control-label col-sm-1">折扣:</label>
                            <div class="col-sm-2">
                                <select  name="buyDiscount"  class="form-control">
                                    <option value="">请选择</option>
                                    <option value="0"  >无折扣</option>
                                    <option value="1"  >有折扣</option>
                                </select>
                            </div>
                            <label class="control-label col-sm-1">开始时间:</label>
                            <div class="col-sm-2">
                                <input type="text" id="beginDate"  name="beginDate" placeholder="请选择交期开始时间" class="form-control">
                            </div>
                            <label class="control-label col-sm-1">结束时间:</label>
                            <div class="col-sm-1">
                                <input type="text" id="endDate"  name="endDate" placeholder="请选择交期结束时间" class="form-control">
                            </div>

                            <a class="search-btn btn btn-success" style="margin-bottom: 0px;">查询</a>
                        </div>
                    </form>
                </div>
            </div>

            <div id="toolbar" class="btn-group" style="margin-bottom:5px;">
                <button  class="report-btn layui-btn  layui-btn-sm"  style="margin-top: -6px;margin-left: -4px">
                    <i class="fa fa-check-square-o" aria-hidden="true"></i> 生成采购订单
                </button>
                <button  class="export-btn layui-btn  layui-btn-sm" style="margin-top: -6px;margin-left: -4px">
                    <i class="fa fa-download" aria-hidden="true"></i> 导出当前数据
                </button>

                <button  class="order-date-btn layui-btn  layui-btn-sm layui-btn-warm" style="margin-top: -6px;margin-left: -4px">
                    <i class="fa fa-link" aria-hidden="true"></i> 修改交期
                </button>

                <button  class="order-discount-btn layui-btn  layui-btn-sm layui-btn-danger" style="margin-top: -6px;margin-left: -4px">
                    <i class="fa fa-link" aria-hidden="true"></i> 修改折扣
                </button>
                <button  class="del-btn layui-btn  layui-btn-sm layui-btn-info" style="margin-top: -6px;margin-left: -4px">
                    <i class="fa fa-link" aria-hidden="true"></i> 删除订单
                </button>
                <button  class="supplier-btn layui-btn  layui-btn-sm layui-btn-default" style="margin-top: -6px;margin-left: -4px">
                    <i class="fa fa-link" aria-hidden="true"></i> 同步供应商
                </button>
                <button  class="edit-supplier-btn layui-btn  layui-btn-sm layui-btn-warm" style="margin-top: -6px;margin-left: -4px">
                    <i class="fa fa-link" aria-hidden="true"></i> 修改供应商
                </button>
            </div>
    <!-- START 数据表格 -->
    <table id="portTable"
           data-toolbar="#toolbar"
           data-side-pagination="server"
           data-pagination="true"
           data-resizable="true"
           data-url="/sea/supply/buy/findByCnd.do"
           data-page-size="15"
           class="table table-striped table-hover"
    >
    </table>
        </div>
    </div>
    <!-- END 数据表格 -->
</div>



<div id="layer_window" style="display: none;overflow-x: hidden;overflow-y: hidden">
    <!-- START 内容部分 -->
    <div class="container" >
        <form class="form-horizontal" id="info-form" method="post" autocomplete="off" style="margin: auto">
            <input type="hidden" id="id" name="id">
            <div class="form-group" style="margin-top: 20px">
                <label class="category control-label col-sm-2" style="max-width: 100px">SKU</label>
                <div class="col-sm-6" style="max-width: 300px">
                    <input type="text" id="orderSku" name="orderSku" readonly value="" class="form-control">
                </div>
            </div>
            <div class="form-group" style="margin-top: 20px">
                <label class="category control-label col-sm-2" style="max-width: 100px">请购数量</label>
                <div class="col-sm-6" style="max-width: 300px">
                    <input type="text" id="orderOldNumber"  readonly value="" class="form-control"><label style="color: red">*拆分不能超过此数量</label>
                </div>
            </div>
            <div class="form-group" style="margin-top: 20px">
                <label class="category control-label col-sm-2" style="max-width: 100px">拆分数量</label>
                <div class="col-sm-6" style="max-width: 300px">
                    <input type="text" id="buyNumber" name="buyNumber" value="" class="form-control"  onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" >
                </div>
            </div>
            <div class="form-group" style="margin-top: 20px">
                <label class="category control-label col-sm-2" style="max-width: 100px">预计交期</label>
                <div class="col-sm-6" style="max-width: 300px">
                    <input type="text" id="buyOrderDate" name="buyOrderDate" value="" class="form-control">
                </div>
            </div>
            <div class="form-group" style="margin-top: 20px">
                <label class="control-label col-sm-7" style="max-width: 100px"></label>
                <button type="button" class="save-btn btn btn-primary">
                    <i class="fa fa-save"></i> 保存
                </button>
            </div>
        </form>
    </div>
    <!-- END 内容部分 -->
</div>

<div id="layer_buy_date_window" style="display: none;overflow-x: hidden;overflow-y: hidden">
    <!-- START 内容部分 -->
    <div class="container" >
        <form class="form-horizontal" id="info-date-form" method="post" autocomplete="off" style="margin: auto">

            <div class="form-group" style="margin-top: 20px">
                <label class="category control-label col-sm-2" style="max-width: 100px">预计交期</label>
                <div class="col-sm-6" style="max-width: 300px;max-height: 300px;">
                    <input type="text" id="buyDate" name="buyDate" value="" class="form-control">
                </div>
            </div>
            <div class="form-group" style="margin-top: 20px">
                <label class="control-label col-sm-7" style="max-width: 100px"></label>
                <button type="button" class="save-date-btn btn btn-primary">
                    <i class="fa fa-save"></i> 保存
                </button>
            </div>
        </form>
    </div>
    <!-- END 内容部分 -->
</div>

<div id="layer_edit_supplier_window" style="display: none;overflow-x: hidden;overflow-y: hidden">
    <!-- START 内容部分 -->
    <div class="container" >
        <form class="form-horizontal" id="info-edit-supplier-form" method="post" autocomplete="off" style="margin: auto">

            <div class="form-group" style="margin-top: 20px">
                <label class="category control-label col-sm-2" style="max-width: 100px">供应商</label>
                <div class="col-sm-6" style="max-width: 300px;max-height: 300px;">
                    <input type="text" id="supplierName" name="supplierName" value="" class="form-control">
                </div>
            </div>
            <div class="form-group" style="margin-top: 20px">
                <label class="control-label col-sm-7" style="max-width: 100px"></label>
                <button type="button" class="save-supplier-btn btn btn-primary">
                    <i class="fa fa-save"></i> 保存
                </button>
            </div>
        </form>
    </div>
    <!-- END 内容部分 -->
</div>

<div id="layer_discount_window" style="display: none;overflow-x: hidden;overflow-y: hidden">
    <!-- START 内容部分 -->
    <div class="container" >
        <form class="form-horizontal" id="info-discount-form" method="post" autocomplete="off" style="margin: auto">

            <div class="form-group" style="margin-top: 20px">
                <label class="category control-label col-sm-2" style="max-width: 100px">折扣(%)</label>
                <div class="col-sm-6" style="max-width: 300px;max-height: 300px;">
                    <input type="text" id="buyDiscount" name="buyDiscount" value="" class="form-control">
                </div>
            </div>
            <div class="form-group" style="margin-top: 20px">
                <label class="control-label col-sm-7" style="max-width: 100px"></label>
                <button type="button" class="save-discount-btn btn btn-primary">
                    <i class="fa fa-save"></i> 保存
                </button>
            </div>
        </form>
    </div>
    <!-- END 内容部分 -->
</div>

<div id="layer_supplier_window" style="display: none;overflow-x: hidden;">
    <!-- START 内容部分 -->
    <div class="container" >
        <form class="form-horizontal" id="info-supplier-form" method="post" autocomplete="off" style="margin: auto">
            <div class="form-group" style="margin-top: 20px">
                <label class="category control-label col-sm-2" style="max-width: 100px">供应商</label>
                <div class="col-sm-6" style="max-width: 300px;max-height: 300px;">
                    <select  id="productSupplierId" name="productSupplierId" xm-select="productSupplierId" xm-select-radio xm-select-search>
                        <%for(var dict in supplier){%>
                        <option value="${dict.id}">${dict.supplierName}</option>
                        <%}%>
                    </select>
                    <input type="hidden" name="productSupplierName" id="productSupplierName">
                </div>
            </div>
            <div class="form-group" style="margin-top: 20px">
                <label class="category control-label col-sm-2" style="max-width: 100px">币种</label>
                <div class="col-sm-6" style="max-width: 300px;max-height: 300px;">
                    <select id="produceMoneyType" name="produceMoneyType" class="form-control">
                        <option value="人民币">人民币</option>
                        <option value="美金">美金</option>
                        <option value="英镑">英镑</option>
                        <option value="欧元">欧元</option>
                    </select>
                </div>
            </div>
            <div class="form-group" style="margin-top: 20px">
                <label class="category control-label col-sm-2" style="max-width: 100px">付款方式</label>
                <div class="col-sm-6" style="max-width: 300px;max-height: 300px;">
                    <select  id="paymentType" name="paymentType" xm-select="paymentType" xm-select-radio xm-select-search>
                        <%for(var dict in payment){%>
                        <option value="${dict.detailName}">${dict.detailName}</option>
                        <%}%>
                    </select>

                </div>
            </div>
            <div class="form-group" style="margin-top: 20px">
                <label class="control-label col-sm-7" style="max-width: 100px"></label>
                <button type="button" class="save-produce-btn btn btn-primary">
                    <i class="fa fa-save"></i> 保存
                </button>
            </div>
        </form>
    </div>
    <!-- END 内容部分 -->
</div>

<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,bootstrap-table,dtvalidate,dtvalidate-lang-zh_cn,bootstrap-table-zh-CN,laydate,layer,chosen,chosen-demo'}){}%>
<script>
    laydate.render({
        elem: '#buyOrderDate' //指定元素
        ,trigger: 'click'
    });
    laydate.render({
        elem: '#beginDate' //指定元素
        ,trigger: 'click'
    });
    laydate.render({
        elem: '#endDate' //指定元素
        ,trigger: 'click'
    });
    laydate.render({
        elem: '#buyDate' //指定元素
        ,trigger: 'click'
    });


    var $portTable = $('#portTable');
    $(function(){
        //START 表格配置
        $portTable.bootstrapTable({
            pageSize:30,
            pageList: [10, 15, 20, 200,2000],
            columns: [
                {
                    field: 'state',
                    checkbox: true,
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '请购单号',
                    field: 'orderNo',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '渠道',
                    field: 'orderChannelName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: 'SKU',
                    field: 'orderSku',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '产品名称',
                    field: 'productName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '产品颜色',
                    field: 'productColorName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '尺码',
                    field: 'productSizeName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '尺码(Inch)',
                    field: 'productInch',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '尺码(Cm)',
                    field: 'productCm',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '请购数量',
                    field: 'buyNumber',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '预计交期',
                    field: 'buyOrderDate',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '折扣',
                    field: 'buyDiscount',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v, r) {
                        if(v>0){
                            return  v*100+'折';
                        }else{
                            return '暂无折扣';
                        }
                    }
                },
                {
                    title: '供应商',
                    field: 'supplierName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    field: 'operate',
                    title: '操作',
                    align: 'center',
                    valign: 'middle',
                    formatter: optFormatter
                }
            ],
            onLoadSuccess : function(){
                $('.split-btn').on('click',function () {
                    $("#id").val($(this).attr('data-val'));
                    $("#orderOldNumber").val($(this).attr('data-val-number'));
                    $("#orderSku").val($(this).attr('data-val-sku'));
                    $("#buyOrderDate").val($(this).attr('data-val-date'));
                    layer.open({
                        type:1,
                        title:'拆分请购单明细',
                        area:['550px','370px'],
                        skin:'layui-layer-lan',//layui-layer-molv ;layui-layer-lan;layui-layer-rim;layer-window
                        shadeClose:false,
                        resize: false,
                        scrollbar: false,
                        maxmin: false,//出现最大化按钮
                        content:$('#layer_window')
                    })
                });
            }
        });

        //操作菜单
        function optFormatter(value,row){
            var content = '';
            content += '<button class="split-btn btn btn-xs btn-success" data-val-date="'+row.buyOrderDate+'" data-val-sku="'+row.orderSku+'" data-val-number="' + row.buyNumber + '" data-val="' + row.id + '" title="拆分"><i class="fa fa-check-square-o" aria-hidden="true"></i> 拆分 </button>';
            return content;
        }
        //END 表格配置


        //提交表单
        $('.save-btn').on('click',function(){
            layer.confirm('确定要拆分当前数据？', {
                btn: ['确定','取消'],title:'提示'
            }, function(){

                layer.closeAll();
                var index=layer.load();
                $.post('/sea/supply/buy/split.do',{id:$("#id").val(),buyNumber:$("#buyNumber").val(),buyOrderDate:$("#buyOrderDate").val()},function(data){
                    if( data.ok ){
                        $portTable.bootstrapTable('refresh');
                        layer.msg(data.msg,{icon:1,time:1500,shade: [0.8, '#393D49']});
                        layer.close(index);
                    }else{
                        layer.msg(data.msg,{icon: 0,time:1500,shade: [0.8, '#393D49']});
                        layer.close(index);
                    }
                });
            });
        });
    });
    $('.report-btn').on('click',function () {
        layer.open({
            type:1,
            title:'生成采购单',
            area:['450px','370px'],
            skin:'layui-layer-lan',//layui-layer-molv ;layui-layer-lan;layui-layer-rim;layer-window
            shadeClose:false,
            resize: false,
            scrollbar: false,
            maxmin: false,//出现最大化按钮
            content:$('#layer_supplier_window')
        })
    });



    $('.order-date-btn').on('click',function () {
        layer.open({
            type:1,
            title:'修改交期',
            area:['450px','270px'],
            skin:'layui-layer-lan',//layui-layer-molv ;layui-layer-lan;layui-layer-rim;layer-window
            shadeClose:false,
            resize: false,
            scrollbar: false,
            maxmin: false,//出现最大化按钮
            content:$('#layer_buy_date_window')
        })
    });

    $('.edit-supplier-btn').on('click',function () {
        layer.open({
            type:1,
            title:'修改供应商',
            area:['450px','270px'],
            skin:'layui-layer-lan',//layui-layer-molv ;layui-layer-lan;layui-layer-rim;layer-window
            shadeClose:false,
            resize: false,
            scrollbar: false,
            maxmin: false,//出现最大化按钮
            content:$('#layer_edit_supplier_window')
        })
    });

    $('.order-discount-btn').on('click',function () {
        layer.open({
            type:1,
            title:'修改折扣',
            area:['450px','270px'],
            skin:'layui-layer-lan',//layui-layer-molv ;layui-layer-lan;layui-layer-rim;layer-window
            shadeClose:false,
            resize: false,
            scrollbar: false,
            maxmin: false,//出现最大化按钮
            content:$('#layer_discount_window')
        })
    });

    $('.save-discount-btn').on('click',function () {
        var buyDiscount=$("#buyDiscount").val();
        if(buyDiscount==''){
            parent.layer.msg('请填写折扣！',{icon: 0,time:1500,shade: [0.8, '#393D49']});
            return;
        }
        var selDatas = $portTable.bootstrapTable('getSelections');
        if( selDatas.length == 0 ){
            layer.msg('请选择要折扣的数据',{icon: 0,shade: [0.8, '#393D49'],time: 1500});
        }else{
            var ids = [];
            $.each(selDatas,function(i,d){
                ids.push(d.id);
            });
            ids = ids.join(',');
            $.ajax({
                url: "/sea/supply/buy/updateOderDiscount",
                data: {

                    buyIds:ids,
                    buyDiscount:buyDiscount
                },
                type: "post",
                success: function (data) {
                    if(data.ok){
                        layer.msg("生成成功！",{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                                layer.closeAll();
                                $portTable.bootstrapTable('refresh');
                            }});
                    }else{
                        layer.msg(data.msg,{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                                layer.closeAll();
                            }});
                    }
                },
            });
        }
    });


    $('.del-btn').on('click',function () {

        var selDatas = $portTable.bootstrapTable('getSelections');
        if( selDatas.length == 0 ){
            layer.msg('请选择要生成的数据',{icon: 0,shade: [0.8, '#393D49'],time: 1500});
        }else{
            var ids = [];
            $.each(selDatas,function(i,d){
                ids.push(d.id);
            });
            ids = ids.join(',');
            $.ajax({
                url: "/sea/supply/buy/delOrder",
                data: {
                    buyIds:ids
                },
                type: "post",
                success: function (data) {

                    if(data.ok){
                        layer.msg(data.msg,{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                                layer.closeAll();
                                $portTable.bootstrapTable('refresh');
                            }});
                    }else{
                        layer.msg(data.msg,{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                                layer.closeAll();
                            }});
                    }
                },
            });
        }
    });

    $('.save-supplier-btn').on('click',function () {
        var supplierName=$("#supplierName").val();
        if(supplierName==''){
            parent.layer.msg('请填写供应商！',{icon: 0,time:1500,shade: [0.8, '#393D49']});
            return;
        }
        var selDatas = $portTable.bootstrapTable('getSelections');
        if( selDatas.length == 0 ){
            layer.msg('请选择要生成的数据',{icon: 0,shade: [0.8, '#393D49'],time: 1500});
        }else{
            var ids = [];
            $.each(selDatas,function(i,d){
                ids.push(d.id);
            });
            ids = ids.join(',');
            $.ajax({
                url: "/sea/supply/buy/updateSupplierName",
                data: {
                    buyIds:ids,
                    supplierName:supplierName
                },
                type: "post",
                success: function (data) {

                    if(data.ok){
                        layer.msg(data.msg,{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                                layer.closeAll();
                                $portTable.bootstrapTable('refresh');
                            }});
                    }else{
                        layer.msg(data.msg,{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                                layer.closeAll();
                            }});
                    }
                },
            });
        }
    });

    $('.save-date-btn').on('click',function () {
        var buyDate=$("#buyDate").val();
        if(buyDate==''){
            parent.layer.msg('请选择交期！',{icon: 0,time:1500,shade: [0.8, '#393D49']});
            return;
        }
        var selDatas = $portTable.bootstrapTable('getSelections');
        if( selDatas.length == 0 ){
            layer.msg('请选择要生成的数据',{icon: 0,shade: [0.8, '#393D49'],time: 1500});
        }else{
            var ids = [];
            $.each(selDatas,function(i,d){
                ids.push(d.id);
            });
            ids = ids.join(',');
            $.ajax({
                url: "/sea/supply/buy/updateOderDate",
                data: {
                    buyIds:ids,
                    buyDate:buyDate
                },
                type: "post",
                success: function (data) {

                    if(data.ok){
                        layer.msg(data.msg,{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                                layer.closeAll();
                                $portTable.bootstrapTable('refresh');
                            }});
                    }else{
                        layer.msg(data.msg,{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                                layer.closeAll();
                            }});
                    }
                },
            });
        }
    });

    $(".save-produce-btn").on('click',function () {
        var supplierName=formSelects.value('productSupplierId', 'nameStr');
        if(supplierName==''){
            parent.layer.msg('请先选择供应商！',{icon: 0,time:1500,shade: [0.8, '#393D49']});
            return;
        }
        var produceMoneyType=$("#produceMoneyType").val();
        if(produceMoneyType==''){
            parent.layer.msg('请选择币种！',{icon: 0,time:1500,shade: [0.8, '#393D49']});
            return;
        }
        var selDatas = $portTable.bootstrapTable('getSelections');
        if( selDatas.length == 0 ){
            layer.msg('请选择要生成的数据',{icon: 0,shade: [0.8, '#393D49'],time: 1500});
        }else{
            var ids = [];
            var flag=true;
            $.each(selDatas,function(i,d){
                ids.push(d.id);
            });
            ids = ids.join(',');
            if(flag==true) {
                var index= layer.load(2, { //icon支持传入0-2
                    shade: [0.1, '#fff'], //0.5透明度的灰色背景
                    content: '正在生成采购单订单,请稍后...',
                    success: function (layero) {
                        layero.find('.layui-layer-content').css({
                            'padding-top': '39px',
                            'margin-left': '-50px',
                            'width': '300px',
                            'font-color': 'red',
                            'font-size': '20px'
                        });
                    }
                });

                $.ajax({
                    url: "/sea/supply/buy/produce",
                    data: {
                        supplierName:supplierName,
                        buyIds:ids,
                        produceMoneyType:produceMoneyType,
                        paymentType:formSelects.value('paymentType', 'nameStr')
                    },
                    type: "post",
                    success: function (data) {
                        if(data.ok){
                            layer.msg(data.msg,{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                                    layer.closeAll();
                                    $portTable.bootstrapTable('refresh');
                                }});
                        }else{
                            layer.msg(data.msg,{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                                    layer.closeAll();
                                }});
                        }
                    },
                });
            }
        }
    });


    $(".supplier-btn").on('click',function () {

        var index= layer.load(2, { //icon支持传入0-2
            shade: [0.1, '#fff'], //0.5透明度的灰色背景
            content: '正在同步供应商,请稍后...',
            success: function (layero) {
                layero.find('.layui-layer-content').css({
                    'padding-top': '39px',
                    'margin-left': '-50px',
                    'width': '300px',
                    'font-color': 'red',
                    'font-size': '20px'
                });
            }
        });

        $.ajax({
            url: "/sea/supply/buy/supplier",
            data: {

            },
            type: "post",
            success: function (data) {
                if(data.ok){
                    layer.msg(data.msg,{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                            layer.closeAll();
                            $portTable.bootstrapTable('refresh');
                        }});
                }else{
                    layer.msg(data.msg,{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){ // 默认的是 按钮一
                            layer.closeAll();
                        }});
                }
            },
        });
    })

    $('.search-btn').on('click',function(){
        $portTable.bootstrapTable('refresh', { url:'${ctxPath}/sea/supply/buy/findByCnd.do?'+$('#search-form').serialize() });
    });

    $(".export-btn").click(function () {
        window.location.href='/sea/supply/buy/export.do?'+$('#search-form').serialize();
    });

</script>
</body>
</html>
